#ifndef NETWORKBASICS_H
#define NETWORKBASICS_H


#include "raknet/MessageIdentifiers.h"
#include "raknet/RakNetworkFactory.h"
#include "raknet/RakPeerInterface.h"
#include "raknet/RakNetTypes.h"

#include "raknet/BitStream.h"
#include "raknet/RakSleep.h"
#include "raknet/RakString.h"
#include "raknet/StringCompressor.h"


#include <string>


using namespace RakNet;




class networkBasics {


    public:


        struct StructMsgLogin {
            std::string name, pass;
            void Write(BitStream *bs) {
                StringCompressor::Instance()->EncodeString(name.c_str(), 256, bs);
                StringCompressor::Instance()->EncodeString(pass.c_str(), 256, bs);
            }
            void Read(BitStream *bs) {
                char buffer[256];
                StringCompressor::Instance()->DecodeString(buffer, 256, bs);
                name = buffer;
                StringCompressor::Instance()->DecodeString(buffer, 256, bs);
                pass = buffer;
            }
        };


        struct StructMsgChat {
            std::string message;
            std::string sTime;
            int sender;
            void Write(BitStream *bs) {
                StringCompressor::Instance()->EncodeString(message.c_str(), 2048, bs);
                StringCompressor::Instance()->EncodeString(sTime.c_str(), 256, bs);
                bs->Write(sender);
            }
            void Read(BitStream *bs) {
                char buffer[2048], sbuffer[2048];
                StringCompressor::Instance()->DecodeString(buffer, 2048, bs);
                message = buffer;
                StringCompressor::Instance()->DecodeString(sbuffer, 256, bs);
                sTime = sbuffer;
                bs->Read(sender);
            }
        };



        struct StructMsgPositition {

            long x, y;

            void Write(BitStream *bs) {
                bs->Write(x);
                bs->Write(y);
            }

            void Read(BitStream *bs) {
                bs->Read(x);
                bs->Read(y);
            }
        };



        struct StructMsgShowCharacters {
            std::string name;
            int id;
            void Write(BitStream *bs) {
                StringCompressor::Instance()->EncodeString(name.c_str(), 256, bs);
                bs->Write(id);
            }
            void Read(BitStream *bs) {
                char buffer[256];
                StringCompressor::Instance()->DecodeString(buffer, 256, bs);
                name = buffer;
                bs->Read(id);
            }
        };




        networkBasics();
        virtual ~networkBasics();
    protected:
    private:
};

#endif // NETWORKBASICS_H

